#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

set<string> ss {
    "319", 
    "680", 
    "180", 
    "690", 
    "129", 
    "620", 
    "762", 
    "689", 
    "762", 
    "318", 
    "368", 
    "710", 
    "720", 
    "710", 
    "629", 
    "168", 
    "160", 
    "689", 
    "716", 
    "731", 
    "736", 
    "729", 
    "316", 
    "729", 
    "729", 
    "710", 
    "769", 
    "290", 
    "719", 
    "680", 
    "318", 
    "389", 
    "162", 
    "289", 
    "162", 
    "718", 
    "729", 
    "319", 
    "790", 
    "680", 
    "890", 
    "362", 
    "319", 
    "760", 
    "316", 
    "729", 
    "380", 
    "319", 
    "728", 
    "716", 
};

int main() {
    vector<set<int>> before(10);
    vector<set<int>> after(10);
    set<int> select;
    for (auto s : ss) {
        int a = s[0] - '0';
        int b = s[1] - '0';
        int c = s[2] - '0';
        after[a].insert(b);
        after[a].insert(c);
        after[b].insert(c);
        before[b].insert(a);
        before[c].insert(a);
        before[c].insert(b);
        select.insert(a);
        select.insert(b);
        select.insert(c);
    }

    while (select.size()) {
        for (auto e : select) {
            if (before[e].size() == 0) {
                cout << e;
                for (auto b : select)
                    before[b].erase(e);
                select.erase(e);
            }
        }
    }
    cout << endl;
}